package com.hhc.controller.message_master;

import com.alibaba.fastjson.JSONObject;
import com.hhc.model.MessageMaster;
import com.hhc.model.MessageMasterExt;
import com.hhc.service.MessageMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/messageMaster")
public class MessageMasterController {
    @Autowired
    private MessageMasterService messageMasterService;

    @RequestMapping(value = "/addMessage", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject addMessage(@RequestBody String data) {
        JSONObject jsonObject;
        MessageMaster messageMaster = JSONObject.parseObject(data, MessageMaster.class);
        jsonObject = messageMasterService.addMessage(messageMaster);
        return jsonObject;
    }

    @RequestMapping(value = "/queryMessageList", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject queryMessageList(@RequestBody String data) {
        JSONObject jsonObject;
        MessageMasterExt messageMasterExt = JSONObject.parseObject(data, MessageMasterExt.class);
        jsonObject = messageMasterService.queryMessageList(messageMasterExt);
        return jsonObject;
    }

    @RequestMapping(value = "/updateMessage", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateMessage(@RequestBody String data) {
        JSONObject jsonObject;
        MessageMasterExt messageMasterExt = JSONObject.parseObject(data, MessageMasterExt.class);
        jsonObject = messageMasterService.updateMessage(messageMasterExt);
        return jsonObject;
    }

}
